<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="pl.swspiz.*" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

User currentUser = (User)(session.getAttribute("currentSessionUser"));
if (currentUser == null){
  
%>
<jsp:forward page="/LoginPage.jsp"/>

<% } %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>
    <% 
     Unit unit = null;
  	//przypisanie obiektu jednostki (unit) z bazy
        if (request.getAttribute("unit") != null){
	unit = (Unit)request.getAttribute("unit");
        out.println("Edycja Rekordu");
        } else {
        unit = new Unit("",1f);
        out.println("Nowy Rekord");
        }
     
     
    %>


    </title>

    
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>
 
  
  <body>
 Zalogowany:
 <%= currentUser.getFirstName() %>
 <br/>
	<form name="edit" action="unitEdit" method="post">
		<table border="0">
			<tbody>
				<tr>
					<td>Nazwa:</td>
					<td><input type="text" name="nazwa" value="<%=unit.getName()%>"></td>
					</tr><tr>		
					<td>Mnoznik:</td>
					<td><input type="text" name="wsp" value="<%=unit.getWsp()%>"></td>
					</tr><tr>	
					<td colspan="2">
                                            <input type="hidden" name="id" value="<%=unit.getName()%>">
                                            <input type="submit" name="btnSave" value="Zapisz"></td>
				</tr>
			</tbody>
		</table>
		
	</form>
<br/><a href="<%out.print(request.getContextPath()); %>/listRecords"><strong>Panel administracyjny</strong></a>
  </body>
</html>
